welcome back to another module of collect data from SQL databases the SQL databases may have MySQL, may have PostgreSQL they are all on the server side and you have to connect with the server and then communicate with the server and then retrieve data from the server in this module we are going to introduce Sqlite which is a data file containing all the needed information without have a server that will make it a little bit easier for us to demonstrate the steps needed to communicate with SQL database however all these three SQL databases I just mentioned MySQL, PostgreSQL, and Sqlite are sharing the same general steps so once you learn how to do with Sqlite you will have no difficulty to communicate with a MySQL or PostgreSQL they just need some extra information such as account, password etc okay so what is the Sqlite as I said Sqlite is a one file containing everything style that has the schema has the data etc the sqlite can be used as a sample of a SQL database and the general steps of a Sqlite how to read data from a Sqlite and following this kind of 6 steps we first need to create a connection and this connection, you can think about it is the panel for communication then after that you are going to create a cursor object this cursor object is like you have an ambassador or you have a worker to communicate for you to that server to that database and then once you have the cursor created you are going to ask the cursor to do something that something is a query once you have the query you are going to ask the cursor to execute that query and then fetch the result back to you as the communication process once you have the results you can either process or manipulate or store the results into your data frame etc once everything is done you can close the connection so you can move on to your next step now let's look at this example and how we can connect with a file I stored in our Google Collaboratory we first need to import sqlite3 that is the package we need to communicate with a sqlite data store if you are going to communicate with MySQL or PostgreSQL then you need to import the corresponding package you can Google and find what they are once we have the package imported we can call from that package and establish the communication panel, which is connection this connection will need where we can find that data stored and where we can find it at a database and this is the path locally I just uploaded it into Google Colaboratory so you can still click on the 3 dots copy that path and the paste image will here if it is a web server then basically you just post that web address in here as well once we have the panel established as a connection we can create a cursor which is the one actually doing a communication for you from that connection, now we can create a queries this query as you can see is wrapped with triple quotations is because we don't have to worry about single or double quotation inside of the query as well as we can have that query cross multiple lines if you want to make it look beautiful you can even go like this and this select from and where is a typical SQL syntax and this one needs a little bit background of SQL but I think it is pretty straightforward this query is asking all the name of the tables stored in that SQL database and once we have the query established we are going to ask the cursor to execute that query and then we ask the cursor to return the results to us and save that into the results once we print the results we can see that in that sqlite database we have only one table, that is ds_salaries then we can play with this ds_salaries table, and retrieve information from it now we just need to have another new query and because we know that the table name is ds_salary we can use another select everything from the ds_salary query we are going to do the same thing ask the cursor to execute ask the cursor to fetch all the results and save that in here once we print that result we can see that each of the row containing all the values and there are of course a lot we can see that this is 489 basically that is the row number okay definitely this is a lot of information and it is kind of structured but we cannot digest them directly so we have to find a way to save them into a dataframe and you can see that this is actually a list and this list contains all information and each of the row is actually a tuple right so wrapped with parentheses so if that is the case we can try use DataFrame Constructor of course we need to import pandas as well and then we use all the results pass to them into our dataframe and then create a dataframe and then we see what is inside it looks perfect that we have for example 608 rows and we have some of course the data tab is not successfully recognized but at the least we have the big picture recognized pretty well and we can see that when we do the first row it is actually the name of the columns and the things we just need to do is we are going to make this row a list and then make the list to the columns and assign the columns to the name of the columns and then we print it out we are able to see that the name of the columns is updated of course we still have to drop the first row so that those names of the columns will be removed and then we can get the results which is similar than we have experienced before from other data types and then this will be the end of connecting data from the SQL database once we done that we are going to say you can get off the job to the cursor that your job is done and then you are going to close that connection